class Stack:
    def __init__(self):
        self.items = []

    def is_empty(self):
        return self.items == []

    def push(self, value):
        self.items.append(value)
    
    def pop(self):
        if self.is_empty():
            return None
        return self.items.pop()
    
    def size(self):
        return len(self.items)


class Queue:
    def __init__(self):
        self.stack1 = Stack()
        self.stack2 = Stack()
    
    def enqueue(self, value):
        self.stack1.push(value)

    def dequeue(self):
        if not self.stack1.is_empty():
            while self.stack1.size() > 0:
                self.stack2.push(self.stack1.pop())
            res = self.stack2.pop()
            while self.stack2.size() > 0:
                self.stack1.push(self.stack2.pop())
            return res


if __name__ == "__main__":
    queue = Queue()
    queue.enqueue(1)
    queue.enqueue(2)
    queue.enqueue(3)

    print(queue.dequeue())
    print(queue.dequeue())

    queue.enqueue(4)
    queue.enqueue(5)

    print(queue.dequeue())
    print(queue.dequeue())
    print(queue.dequeue())
